package com.threeti.mecool.mobile.interfaces.assembler;

import java.util.ArrayList;
import java.util.List;

import org.dozer.Mapper;
import org.springframework.util.CollectionUtils;

import com.threeti.jiayusms.framework.util.DozerMapperSingleton;
import com.threeti.mecool.core.domain.model.Communication;
import com.threeti.mecool.core.domain.model.acl.User;
import com.threeti.mecool.mobile.interfaces.CommunicationDto;
import com.threeti.mecool.mobile.interfaces.UserDto;

public class UserAssembler {
  public static UserDto toDto(User user) {
    Mapper transfer = DozerMapperSingleton.getInstance();
    UserDto destDto = new UserDto();
    transfer.map(user, destDto);
    return destDto;
  }
  
  public static CommunicationDto toDto(Communication srcDom) {
    Mapper transfer = DozerMapperSingleton.getInstance();
    CommunicationDto destDto = new CommunicationDto();
    transfer.map(srcDom, destDto);
    return destDto;
  }
  
  public static List<CommunicationDto> toDtoList(List<Communication> srcDoms) {
    List<CommunicationDto> dtos = null;
    if(!CollectionUtils.isEmpty(srcDoms)){
      dtos = new ArrayList<CommunicationDto>();
      for(Communication comm : srcDoms){
        dtos.add(toDto(comm));
      }
    }
    return dtos;
  }
}
